Fix server cache memory leak #4069
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed the client memory was increasing by 5-10MB every time I reconnected to a local server with no resources running.
Turns out we were not deleting the XML node and file handle in
CServerCache::StaticSaveServerCacheall this time :)Noticed the same in
CServerCache::LoadServerCachetoo, which only runs once - but enjoy the extra memory! Think of all the assets you can fit into 7MB!For context, the "7MB" reduction in memory won't be 7MB for every client. That value is based on the overall size (how many entries) of the client's
MTA/config/servercache.xml. For reference I have 506 server entries (from all the years playing MTA, I guess?), which when converted to the TiXml attribute instances takes up around 7MB in memory.